package com.framework.module_google;

import android.util.Log;

/**
 * @author ： HeXinGen
 * @date ： 2023/6/27
 * @description ：
 * 1. 避免字符串拼接问题，改用stringbuidler
 * 2. 支持打印线程堆
 */
public class LogUtils {
   private static final  String TAG="app_log";

   /**
    * 打印普通日志
    * @param content
    */
   public static void printI(Object ... content){
      Log.i(TAG,buildStr(content));
   }
   public static void printW(Object ... content){
      Log.w(TAG,buildStr(content));
   }
   /**
    * 打印当前线程调用栈
    */
   public static void  printThreadStack(){
      String stack=Log.getStackTraceString(new Exception("passExGetThreadStack"));
      Log.d(TAG,stack);
   }

   private static String buildStr(Object ... contents){
      StringBuilder stringBuilder=new StringBuilder();
      int i=0;
      for (Object o:contents){
         stringBuilder.append(o);
         if (i<contents.length-1){
            stringBuilder.append(" , ");
         }
         i++;
      }
      return stringBuilder.toString();
   }

   /**
    * 打印异常的调用栈
    * @param msg
    * @param throwable
    */
   public static void printException(String msg,Throwable throwable){

      Log.e(TAG,msg,throwable);
   }
}
